<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<h2>学生查询</h2>
<form action="" method="post">
No:<input type="text" name="studentno">&nbsp;&nbsp;&nbsp;
<input type="submit" name="snsearch" value="按照No进行查询">
</form><br/><br/>
<form action="" method="post">
姓名:<input type="text" name="studentname">&nbsp;&nbsp;&nbsp;
<input type="submit" name="stunamesearch" value="按照姓名进行模糊查询">
</form><br/><br/>
<form action="" method="post">
学号:<input type="text" name="number">&nbsp;&nbsp;&nbsp;
<input type="submit" name="numbersearch" value="按照学号进行模糊查询">
</form><br/><br/>
<form action="" method="post">
手机号:<input type="text" name="mobile">&nbsp;&nbsp;&nbsp;
<input type="submit" name="mobilesearch" value="按照手机号进行模糊查询"><br/><br/>
</form>
<table border="1" width="1050">
<tr>
<td>No</td>
<td>姓名</td>
<td>性别</td>
<td>学号</td>
<td>班级</td>
<td>手机号</td>
<td>信用</td>
<td>查看详情</td>
<td>修改信息</td>
<td>删除书籍</td>
</tr>
<!--接下来开始加载数据库中的内容-->
<?php
$selectsqls="select studentno,studentname,xingbie,number,class,mobile,credit from students ";
//首先判断是否是No查询
if(isset($_POST["snsearch"])&&$_POST["snsearch"]=="按照No进行查询"){
	$studentno=$_POST["studentno"];
	$selectsqls.="where studentno='$studentno'";
}
//判断是否是姓名查询
if(isset($_POST["stunamesearch"])&&$_POST["stunamesearch"]=="按照姓名进行模糊查询"){
	$studentname=$_POST["studentname"];
	$selectsqls.="where studentname like '%{$studentname}%'";
}
//判断是否是学号查询
if(isset($_POST["numbersearch"])&&$_POST["numbersearch"]=="按照学号进行模糊查询"){
	$number=$_POST["number"];
	$selectsqls.="where number like '%{$number}%'";
}
//判断是否是手机号查询
if(isset($_POST["mobilesearch"])&&$_POST["mobilesearch"]=="按照手机号进行模糊查询"){
	$mobile=$_POST["mobile"];
	$selectsqls.="where mobile like '%{$mobile}%'";
}
include_once("database.php");
$result=@mysql_query($selectsqls) or die("查询信息失败:".mysql_error()."<br/>");
if(mysql_num_rows($result)>0){
	while($row=mysql_fetch_array($result,MYSQL_ASSOC)){
		echo "<tr>";
		foreach($row as $value){
			echo "<td>{$value}</td>";
		}

		echo "<td><a href=\"studentxq.php?studentno={$row['studentno']}\" target=\"iframe_main\">查看详情</a></td>";
		echo "<td><a href=\"updatastudent.php?studentno={$row['studentno']}\" target=\"iframe_main\">修改</a></td>";
		echo "<td><a href=\"deletestudent.php?studentno={$row['studentno']}\" target=\"iframe_main\">删除</a></td>";
		echo "</tr>";
	}
}else{
	echo "<script>alert('没有查找到指定的信息!');</script>";
}
?>
</table>
</body>
</html>